package ms.jacrim.tropos;

import org.w3c.dom.Element;

public class Association extends Relationship {

//	public static final String IS_PART_OF = "IS_PART_OF";
//	public static final String IS_A = "IS_A";
//	public static final String COVER = "COVER";
//	public static final String PLAY = "PLAY";
//	public static final String OCCUPY = "OCCUPY";
//	public static final String SUPERVISE = "SUPERVISE";

	public enum Type {
		IS_PART_OF, IS_A, COVER, PLAY, OCCUPY, SUPERVISE
	};

	private static final String ASSOCIATION_TEMPLATE = "<object xmi:type=\"%s\" xmi:id=\"%s\""
			+ " source=\"%s\" target=\"%s\" associationType=\"%s\" />\r\n";

	private Type associationType;

	public Association(Diagram diagram, TroposObject source, TroposObject target) {
		super(diagram, source, target);
		setType(TroposObject.ASSOCIATION);
	}

	public Association(Diagram diagram, Element element) {
		super(diagram, element);
	}

	void populate(Element element) {
		super.populate(element);

		this.associationType = Type.valueOf(element.getAttribute("associationType"));
	}
	
	public Type getAssociationType() {
		return associationType;
	}

	public void setAssociationType(Type associationType) {
		this.associationType = associationType;
	}

	void toString(StringBuilder result, int part, int indent) {
		writeIndent(result, indent);
		result.append(String.format(ASSOCIATION_TEMPLATE, this.getType(), this.getId(), this.getSourceId(), this.getTargetId(),
				this.associationType.toString()));
	}

	@Override
	protected int NotationEdgeType() {
		// TODO Auto-generated method stub
		return 0;
	}
}
